import pandas as pd
from sklearn.preprocessing import MinMaxScaler, StandardScaler


data = pd.read_csv('data/datingTestSet.txt', sep='\t', names=['flight', 'icecream', 'game', 'type'])
print(data)
# 归一化
# 实例化一个转换器 feature_range=(0, 1) 归一化的范围
transfer = MinMaxScaler(feature_range=(0, 1))
minmax_data = transfer.fit_transform(data[['flight', 'icecream', 'game']])
print('经过归一化处理好的数据位:\n', minmax_data)

# 标准化
transfer = StandardScaler()
minmax_data = transfer.fit_transform(data[['flight', 'icecream', 'game']])
print('经过标准化处理好的数据位:\n', minmax_data)

